import os

# def deep(i: int):
#     print(i)
#     if i == 10:
#         print("递归结束")
#     else:
#         return deep(i + 1)
#
#
# deep(1)

#
print(os.listdir("D:/path"))  # 列出文件夹
print(os.path.isdir("D:/path"))  # 判断是否为文件夹
print(os.path.exists("D:/path"))  # 判断文件夹是否存在


# 使用递归，获取文件列表

def get_files(path: str):
    file_list = []
    if os.path.exists(path):
        for f in os.listdir(path):
            new_path = path + "/" + f
            if os.path.isdir(new_path):
                file_list += get_files(new_path)
            else:
                file_list.append(new_path)
    else:
        return file_list

    return file_list


if __name__ == '__main__':
    path = "D:/path"
    print(get_files(path))
